@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set tst="%windir%\$del_me$"
(type nul>%tst%) 2>nul && (del %tst% & set elev=t) || (set elev=)
IF defined elev ( GOTO start
) ELSE (
echo.
echo ERROR, Please run me in elevated mode - Right Click - Run as Administrator
pause
GOTO :eof)

:start
SET OUTPUTDIR="%UserProfile%\Desktop\Logs_AppInstallCollection\%computername%"

IF NOT EXIST %OUTPUTDIR% MD %OUTPUTDIR%

pushd "%OUTPUTDIR%"

echo Collecting Logs...
echo.

wevtutil qe Microsoft-Windows-AppXDeploymentServer/Operational "/q:*[System[(Level=2 or Level=3)]]" /f:text /RD:TRUE > %OUTPUTDIR%\log.txt

popd
echo.
echo Completed... Events stored in %OUTPUTDIR%
echo.
pause
:end